public class Test16 {
    public static int test16(String str) {
        int result = 0;
        
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (c < '0' || c > '9') {
                throw new NumberFormatException("Invalid character: " + c);
            }
            int digit = c - '0';
            result = result * 10 + digit;
        }
        
        return result;
    }

    public static void main(String[] args) {
        String numStr = "12345";
        int num = test16(numStr);
        System.out.println("转换结果: " + num);  // 输出: 12345
    }
}